package com.example.demo.com.example.demo.controller;

import org.apache.poi.hssf.usermodel.*;

import java.io.FileOutputStream;
import java.util.Date;

public class demo1 {
        public static void main(String[] args)  throws  Exception{
            HSSFWorkbook sheets = new HSSFWorkbook();//定义一个新的工作簿
            HSSFSheet sheet= sheets.createSheet("第一给sheet页");//创建sheet页

            HSSFRow row = sheet.createRow(0);//创建行
            HSSFCell cell = row.createCell(0);//创建单元格
            cell.setCellValue("1");//设置值
            HSSFCellStyle cellStyle = sheets.createCellStyle();// 单元格样式
            HSSFCreationHelper creationHelper = sheets.getCreationHelper();
            cellStyle.setDataFormat(creationHelper.createDataFormat().getFormat("yyyy-hh-mm"));
            FileOutputStream fileOutputStream = new FileOutputStream("d:\\我的第一个workboot1.xls");
            cell.setCellStyle(cellStyle);
            cell.setCellValue(new Date());
            sheets.write(fileOutputStream);
            fileOutputStream.close();



        }

}
